package com.ml.service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.util.Assert;

import com.ml.enums.EnumPayStatus;

public class OrderFactory {
	private static Map<EnumPayStatus, StateHandler> services = new ConcurrentHashMap<EnumPayStatus, StateHandler>();

	public static StateHandler getByOrderState(EnumPayStatus payStatus) {
		return services.get(payStatus);
	}

	public static void register(EnumPayStatus payStatus, StateHandler stateHandler) {
		Assert.notNull(payStatus, "order pay state can't be null");
		services.put(payStatus, stateHandler);
	}
}
